//
// Created by mac on 1/26/22.
//

#include <string>
using namespace std;

string reverseWords(string s){
    int n = s.size();

    int left=0;
    while(left<n){
        if(s[left]!=' '){
            int right = left;
            while (right + 1 < n && s[right + 1] != ' '){right++;}

            reverse(s.begin()+left, s.begin()+right+1);
            left = right+1;

        } else{
            left++;
        }

    }
    return s;
}
